import {_decorator, Component} from 'cc';
import {EventManager} from "db://assets/scripts/common/EventManager";
import {EventType} from "db://assets/scripts/common/EventType";

const {ccclass, property} = _decorator;

/**
 * 管理所有界面的可见性
 * 界面管理自己内部控件
 */
@ccclass('UIManager')
export class UIManager extends Component {

    onEnable() {
        // 系统事件

        // 自定义事件
        EventManager.on(EventType.UI_START_MENU_VISIBLE, this.startMenuVisible, this);
    }

    onDisable() {
        // 系统事件

        // 自定义事件
        EventManager.off(EventType.UI_START_MENU_VISIBLE, this.startMenuVisible, this);
    }

    start() {

    }

    /**
     * 开始菜单是否可见
     *
     * @param visible 是否可见
     * @link EventType#UI_START_MENU_VISIBLE
     */
    private startMenuVisible(visible: boolean) {
        this.node.getChildByName("StartMenu").active = visible;
    }

    update(deltaTime: number) {

    }
}

